package com.qiqijuice.sales;

import net.miginfocom.swt.MigLayout;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

public class ProductOrderView extends Composite {
	public static int EVT_ADD_PRODUCT = 0x5000;
	
	ProductListView products;
	
	public ProductOrderView(Composite parent) {
		super(parent, SWT.NONE);
		
		setLayout(new MigLayout("fill, flowy","", "[100][85%]"));
		
		CategoryListView clv = new CategoryListView(this);
		clv.setLayoutData("growx");
		clv.addListener(CategoryListView.EVT_CATEGORY_SELETED, new Listener() {
			
			@Override
			public void handleEvent(Event event) {
				ProductCategory pc = (ProductCategory) event.data;
				products.viewProductCategory(pc);
			}
		});
		
		ProductListView plv = new ProductListView(this);
		plv.setLayoutData("grow");
		products = plv;
		plv.addListener(ProductListView.EVT_PRODUCT_SELETED, new Listener() {

			@Override
			public void handleEvent(Event event) {
				notifyListeners(EVT_ADD_PRODUCT, event);
			}
		});
	}

}
